<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title>操作日志</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/css/thesame.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/framework/css/rightCon.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/framework/css/page.css}" media="all">
</head>

<body class="layui-layout-body">
<div class="layui-body ">
    <!-- 内容主体区域 -->
    <div class="scroll-box">
        <div class="scroll-box-con">
            <div class="crumbs-nav f14px pb16px">
                <span class="current">操作日志</span>
            </div>
            <div class="pad16px border-radius4 bgWhite mb16px">
                <div class="form-style form-box form-inquire">
                    <ul style="width: 48%;">
                        <li class="form-title">
                            <label>操作时间：</label>
                        </li>
                        <li class="form-content">
                            <p class="display-flex">
                                <input type="text" placeholder="请输入" id="day1" class="form-input-time">
                                <span class="ml5px mr5px">-</span>
                                <input type="text" placeholder="请输入" id="day2" class="form-input-time">
                            </p>
                        </li>
                    </ul>
                    <ul style="width: 28%;">
                        <li class="form-title">
                            <label>操作人员：</label>
                        </li>
                        <li class="form-content">
                            <p><input type="text" id="userName" maxlength="10" placeholder="请输入"></p>
                        </li>
                    </ul>
                    <ul style="width: 20%;">
                        <li>
                            <div class="btn-con btn-con-margin lh32px">
                                <span class="btn-inquire" onclick="getRecordList()">查&nbsp;询</span>
                                <span class="btn-reset">重&nbsp;置</span>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="pad16px border-radius4 bgWhite">
                <div class="new-data-btn mb16px lh30px overflow">
                    <p class="right"><span class="block">共<em class="red">120</em>条数据</span></p>
                </div>
                <div class="table-center">
                    <table class="layui-hide" id="test" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/static/js/jquery-3.1.1.min.js}" charset="utf-8"></script>
<script th:src="@{/static/js/date.js}" charset="utf-8"></script>
<script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>
<script th:inline="javascript">

    var basePath = [[${#request.getContextPath()}]];
    var layer = "";

    $(function () {

        $(".btn-reset").click(function(){
            $("input").val('');
        })

        //时间控件初始化
        layui.use(['laydate'], function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#day1' ,
                min: curDay(),
                type: 'date'
            });
            laydate.render({
                elem: '#day2' ,
                min: curDay(),
                type: 'date'
            });
        });

        //列表初始化
        getRecordList();

    });

    //获取列表
    function getRecordList(){

        var startDay = $("#day1").val();
        var endDay = $("#day2").val();
        var userName = $("#userName").val();

        if(!compareTime(startDay, endDay)) {
            console.log("startDay="+startDay);
            console.log("endDay="+endDay);
            layui.use(['layer'], function () {
                layui.layer.msg("操作开始时间不能大于结束时间", {time: "1500"});
            })
            return;
        }
        startDay=startDay.replace(/-/g,"").replace(/ /g,"").replace(/:/g,"");
        endDay=endDay.replace(/-/g,"").replace(/ /g,"").replace(/:/g,"");

        layui.use(['table'], function() {
            var table = layui.table;
            //第一个实例
            table.render({
                elem: '#test'//,url: '/demo/table/user/'
                ,url:"../record/pageRecordList"
                ,where: {"startDay":startDay,"endDay":endDay,"userName":userName}
                ,request: {
                    pageName: 'currentPage' //页码的参数名称，默认：page
                    ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
                }
                //,count: 10  //数据总数，从服务端得到
                //,data: listData
                ,page: true //开启分页
                ,limit:10 //每页显示的条数
                //,limits:[3,4,5]
                ,groups: 9 //连续页码个数
                ,parseData:function(res){
                    return{
                        "code":res.code,
                        "data":res.data,
                        "count":res.totalCount,
                        "limit":res.pageSize,
                    };
                }
                ,cols: [
                    [
                        {
                            field: 'created_time',
                            title: '操作时间',
                        }, {
                        field: 'name',
                        title: '操作类型',
                    }, {
                        field: 'shop_name',
                        title: '操作对象',
                    }, {
                        field: 'org_id',
                        title: '所属区域',
                    },{
                        field: 'user_name',
                        title: '操作人员',
                    }
                    ]
                ]
                ,done:function(res, curr, count){
                    $("#totalNum").text(count);
                    //
                }
            });
        });
    }

    function msg(){

    }



</script>
</body>

</html>
